home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / What's New? / • What was new 03⁄99 / Development Kits / USBDDK_1.2d3 / Examples / USBSampleStorageDriver / SampleStorageHeader.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-18  |  4.2 KB  |  148 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        SampleStorageHeader.c
  3.  
  4.     Contains:    All exported structures and functions for the USB Manager
  5.  
  6.     Version:        1.1
  7.  
  8.     Copyright:    © 1998-1999 by Apple Computer, Inc., all rights reserved.
  9.  
  10. */
  11.  
  12.  
  13.  
  14. #include <MacTypes.h>
  15. #include <Devices.h>
  16. #include <DriverServices.h>
  17. #include <USB.h>
  18.  
  19. #include "SampleStorageDriver.h"
  20. #include "SampleStorageVersion.h"
  21. #include "SampleStorageDeviceID.h"
  22.  
  23. //------------------------------------------------------
  24. //
  25. // Protos
  26. //
  27. //------------------------------------------------------
  28. OSStatus StorageDriverValidateHW(USBDeviceRef device, USBDeviceDescriptor *desc);
  29. OSStatus StorageDriverInitDevice(USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable);
  30. OSStatus StorageDriverInitInterface( UInt32 interfaceNum, USBInterfaceDescriptor *interfaceDesc, USBDeviceDescriptor *deviceDesc, USBDeviceRef device);
  31. OSStatus StorageDriverFinalize(USBDeviceRef device, USBDeviceDescriptorPtr desc );
  32. OSStatus    StorageDriverNotifyProc(UInt32     notification, void *pointer, UInt32 refCon);
  33.  
  34. //------------------------------------------------------
  35. //
  36. //    This is the driver description structure that the expert looks for first.
  37. //  If it's here, the information within is used to match the driver
  38. //  to the device whose descriptor was passed to the expert.
  39. //    Information in this block is also used by the expert when an
  40. //  entry is created in the Name Registry.
  41. //
  42. //------------------------------------------------------
  43. USBDriverDescription    TheUSBDriverDescription = 
  44. {
  45.     // Signature info
  46.     kTheUSBDriverDescriptionSignature,    // 'usbd'
  47.     kInitialUSBDriverDescriptor,            // 0
  48.     
  49.     // Device Info
  50.     kDriverVendorID,                            // USB Vendor ID
  51.     kDriverProductID,                        // USB Product ID.
  52.     0,                                                // Release Number of Device
  53.     0,                                                // Protocol Info.
  54.     
  55.     // Interface Info    (* I don't think this would always be required...*)                
  56.     0,                                                // Configuration Value
  57.     0,                                                // Interface Number
  58.     0,                                                // Interface Class
  59.     0,                                             // Interface SubClass
  60.     0,                                                // Interface Protocol
  61.         
  62.     
  63.     // Driver Info    
  64.     "\pUSB Storage Class",                    // Driver name for Name Registry
  65.     kDriverClassID,                // Device Class  (from USBDeviceDefines.h)
  66.     kDriverSubClassID,                        // Device Subclass 
  67.     kStorageHexMajorVers, kStorageHexMinorVers, kStorageReleaseStage, kStorageCurrentRelease,        // version of driver = 0.0d0
  68.     
  69.     // Driver Loading Info
  70.     0x00000000                                    // Flags (currently undefined)
  71. };
  72.     
  73. USBClassDriverPluginDispatchTable TheClassDriverPluginDispatchTable =
  74. {
  75.     kClassDriverPluginVersion,                // Version of this structure
  76.     StorageDriverValidateHW,                // Hardware Validation Procedure
  77.     StorageDriverInitDevice,                // Initialization Procedure
  78.     StorageDriverInitInterface,            // Interface Initialization Procedure
  79.     StorageDriverFinalize,                    // Finalization Procedure
  80.     StorageDriverNotifyProc,                // Driver Notification Procedure
  81. };
  82.  
  83. // Hardware Validation
  84. // Called upon load by Expert
  85. OSStatus 
  86. StorageDriverValidateHW(    USBDeviceRef            device,
  87.                                     USBDeviceDescriptor    *desc)
  88. {
  89.     device = 0;
  90.     desc = 0;
  91.     return (OSStatus)noErr;
  92. }
  93.  
  94.  
  95. // Initialization function
  96. // Called upon load by Expert
  97. OSStatus 
  98. StorageDriverInitDevice(    USBDeviceRef                device,
  99.                                     USBDeviceDescriptorPtr    pDesc,
  100.                                     UInt32                        busPowerAvailable)
  101. {
  102.     busPowerAvailable = 0;
  103.     
  104.     StorageDriverEntry(device, pDesc, NULL );
  105.     
  106.     return (OSStatus)noErr;
  107. }
  108.  
  109. // StorageDriverInitInterface function
  110. // Called to initialize driver for an individual interface - either by expert or
  111. // internally by driver
  112. OSStatus
  113. StorageDriverInitInterface(    UInt32                         interfaceNum, 
  114.                                         USBInterfaceDescriptor    *interfaceDesc, 
  115.                                         USBDeviceDescriptor        *deviceDesc, 
  116.                                         USBDeviceRef                 device)
  117. {
  118.     interfaceNum = 0;
  119.  
  120.     StorageDriverEntry(device, deviceDesc, interfaceDesc );
  121.     
  122.     return (OSStatus)noErr;
  123. }
  124.  
  125. // Termination function
  126. // Called by Expert when driver is being shut down
  127. OSStatus
  128. StorageDriverFinalize(    USBDeviceRef                device,
  129.                                 USBDeviceDescriptorPtr    desc )
  130. {
  131. #pragma unused(device)
  132. #pragma unused(desc)
  133.  
  134.     StorageClassDriverFinalize();
  135.  
  136.     return (OSStatus)noErr;
  137. }
  138.  
  139. OSStatus    
  140. StorageDriverNotifyProc(UInt32    notification,
  141.                                 void*        pointer,
  142.                                 UInt32    refCon)
  143. {
  144. #pragma unused(refCon)
  145.  
  146.     return(StorageClassDriverNotifyProc(notification, pointer));
  147. }
  148.